import { Injectable } from '@nestjs/common';
import { Repository } from 'typeorm';
import { PageEntity } from './entities';
import { InjectRepository } from '@nestjs/typeorm';
import { CreatePageDto } from './dto';
import { generateUUID } from 'src/common/utils/uuid';

@Injectable()
export class PageService {
  constructor(
    @InjectRepository(PageEntity)
    private readonly pageEntityRep: Repository<PageEntity>,
  ) {}

  async create(createPageDto: CreatePageDto) {
    const pageId = generateUUID();
    const page = {
      ...createPageDto,
      pageId,
    };
    return await this.pageEntityRep.save(page);
  }
}
